import 'package:flutter/material.dart';
import 'package:testflutte/relsease/Utils.dart';

final List<Tab> _titles = <Tab>[
  Tab(
    text: '首页',
  ),
  Tab(
    text: '首页',
  ),
  Tab(
    text: '首页',
  ),
  Tab(
    text: '首页',
  ),
];

class MainPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: DefaultTabController(
          length: _titles.length,
          child: Scaffold(
            appBar: AppBar(
              leading: Container(
                margin: EdgeInsets.all(10.0),
                decoration: BoxDecoration(
                    shape: BoxShape.circle,
                    image: DecorationImage(image: AssetImage(Utils.getimagePath('ali_connors')))),
              ),
              title: TabLayout(),
              centerTitle: true,
              actions: <Widget>[
                IconButton(
                    icon: Icon(Icons.search),
                    onPressed: () {
                      //点击跳转搜索
                    })
              ],
            ),
          )),
    );
  }
}

class TabLayout extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return TabBar(
      tabs: _titles,
      isScrollable: true,
    );
  }
}
